package tom.oauth2;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * https://www.cnblogs.com/wunaozai/p/9205550.html
 * 访问非授权url: http://localhost:8080/hi 正常返回
 * 访问授权url: http://localhost:8080/order 提示未授权
 * 注意level=debug日志
 * 密码模式:
 *  获取access_token: client
 *  	http://localhost:8080/oauth/token?grant_type=password&scope=select&username=admin&password=123456&client_id=client&client_secret=123456
 * 	返回json包含access_token
 * 	再次访问	: http://localhost:8080/order?access_token=9682bc84-af95-43aa-8682-86405dab1198
 *
 * 客户端模式:
 *	http://localhost:8080/oauth/token?grant_type=client_credentials&scope=select&client_id=client&client_secret=123456
 *  返回json中包含access_token
 *
 * code模式：先通过上面两种方式的一种获取access_token,然后访问
 * 	 http://localhost:8080/oauth/authorize?response_type=code&scope=select&client_id=client&access_token=90ce8731-08d3-44fb-bb6a-3d0f332499cb&redirect_uri=http://localhost:8080/login
 * 	 注意：redirect_uri要和BaseClientDetailService中client对应的registeredRedirectUri相同
 * 	 验证通过后将跳转到redirect_uri并且传递参数code=xxxx,然后第三方用code请求获取access token , code只能使用一次
 * 	 用授权码获取access token:
 *   http://localhost:8080/oauth/token?grant_type=authorization_code&client_id=client&client_secret=123456&code=Yr7Xga&redirect_uri=http://localhost:8080/login
 *
 * token检查有效性
 *  http://localhost:8080/oauth/check_token?token=90ce8731-08d3-44fb-bb6a-3d0f332499cb
 *
 * 刷新token, 生成新的token, expire时间会变长
 *  http://localhost:8080/oauth/token?grant_type=refresh_token&refresh_token=219394ad-a36a-4e34-8425-cfa0b2e7e5cf&client_id=client&client_secret=123456
 * @author ZHUFEIFEI
 */
@SpringBootApplication
public class Oauth2demo02Application {

	public static void main(String[] args) {
		SpringApplication.run(Oauth2demo02Application.class, args);
	}

}

